var mongoose = require('mongoose');
require('../model/user.model');
var userModel = mongoose.model('User');

module.exports={
    findByUserName:findByUserName,
    findAll:findAll
};

function findAll(callback){
    userModel.find({}).exec(function(err,doc){
        callback(err,doc);
    });
}

/**
 * find user by ids
 * @param userid
 */
function findByUserName(username,callBack){
    userModel.findOne({username:username}).exec(function(err,doc){
        callBack(err,doc);
    });
}